package edu.bw.service.impl;

import edu.bw.mapper.ProductMapper;
import edu.bw.po.Product;
import edu.bw.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
//    @Transactional(readOnly = true)
    public List<Product> findAll() {
        return productMapper.findAll();
    }

    @Override
    @Transactional
    public void updateProduct(Product product) {
//        int i=1/0;
        productMapper.updateProduct(product);
    }

    @Override
    @Transactional
    public void deleteByPid(Integer pid) {
        productMapper.deleteByPid(pid);
    }

    @Override
    @Transactional
    public void saveProduct(Product product) {
        productMapper.saveProduct(product);
    }
}
